<?php
/***************************************************************************
*
*	AuctionTheme - copyright (c) - sitemile.com
*	The most popular auction theme for wordress on the internet. Launch your
*	auction site in minutes from purchasing. Turn-key solution.
*
*	Coder: Andrei Dragos Saioc
*	Email: sitemile[at]sitemile.com | andreisaioc[at]gmail.com
*	More info about the theme here: http://sitemile.com/p/auctionTheme
*	since v4.4.7.1
*
***************************************************************************/

function AuctionTheme_my_account_payments_area_function()
{
	
		global $current_user, $wpdb, $wp_query;
		get_currentuserinfo();
		$uid = $current_user->ID;
	
	
	?>	
		<div id="content">
        
           <?php
			
			$pg = $_GET['pg'];
			if(!isset($pg)) $pg = 'home';
			
			
			
			global $wpdb;
			
			if($_GET['pg'] == 'closewithdrawal')
					{
						$id = $_GET['id'];
						
						$s = "select * from ".$wpdb->prefix."auction_withdraw where id='$id' AND uid='$uid'";
						$r = $wpdb->get_results($s);
						
						if(count($r) == 1)
						{
							$row = $r[0];
							$amount = $row->amount;
							
							$cr = auctionTheme_get_credits($uid);
							auctionTheme_update_credits($uid, $cr + $amount);
							
							$s = "delete from ".$wpdb->prefix."auction_withdraw where id='$id' AND uid='$uid'";
							$wpdb->query($s);
						
							echo __('Request canceled!','AuctionTheme').'<br/><br/>';	
						}
					}
					
					
					if($_GET['pg'] == 'releasepayment')
					{
						$id = $_GET['id'];
						
						$s = "select * from ".$wpdb->prefix."auction_escrow where id='$id' AND fromid='$uid'";
						$r = $wpdb->get_results($s);
						
						if(count($r) == 1)
						{
							$row = $r[0];
							$amount = $row->amount;
							$toid = $row->toid;
							
							$cr = auctionTheme_get_credits($toid);
							auctionTheme_update_credits($toid, $cr + $amount);
							
							$reason = sprintf(__('Payment received from %s','AuctionTheme'), $current_user->user_login);
							auctionTheme_add_history_log('1', $reason, $amount, $toid, $uid);
							
							//--------------------------------
							$bid_id = $row->bid_id;
							
							$wpdb->query("update ".$wpdb->prefix."auction_bids set paid='1' where id='$bid_id'");
							update_post_meta($pid, 'paid_on_'.$bid_id, current_time('timestamp',0));
							
							//-----------------------------
							$email 		= get_bloginfo('admin_email');
							$site_name 	= get_bloginfo('name');
							
							$usr = get_userdata($uid);
							
							$subject = __("Money Escrow Completed",'AuctionTheme');
							$message = sprintf(__("You have released the escrow of: %s","AuctionTheme"), auctionTheme_get_show_price($amount,2));
	
							//sitemile_send_email($usr->user_email, $subject , $message);
							
							//-----------------------------
							
							$usr = get_userdata($toid);
							
							$reason = sprintf(__('Payment sent to %s','AuctionTheme'), $usr->user_login);
							auctionTheme_add_history_log('0', $reason, $amount, $uid, $toid);
							
							$subject = __("Money Escrow Completed","AuctionTheme");
							$message = sprintf(__("You have received the amount of: %s","AuctionTheme"), auctionTheme_get_show_price($amount,2));
	
							//sitemile_send_email($usr->user_email, $subject , $message);
							
							//-----------------------------
							$tm = current_time('timestamp',0);
							$s = "update ".$wpdb->prefix."auction_escrow set released='1', releasedate='$tm' where id='$id'";
							$r = $wpdb->query($s);
						
							echo __('Escrow completed! Redirecting...','AuctionTheme'); echo '<br/><br/>';	
							
							$url_redir = get_bloginfo('siteurl').'/my-account/payments/';
							echo '<meta http-equiv="refresh" content="2;url='.$url_redir.'" />';
							
						}
					}
			
			
			if($pg == 'home'):
			?>
            
            
            
            <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e("Payments","AuctionTheme"); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
                
                <?php
				$bal = auctionTheme_get_credits($uid);
				echo '<span class="balance">'.__("Your Current Balance is", "AuctionTheme").": ".auctionTheme_get_show_price($bal)."</span>"; 
				
				
				?> 
    
    
                  
                </div></div>
            </div>
            </div>
            
            <div class="clear10"></div>
            
            <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e('What do you want to do','AuctionTheme'); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
                
                <a href="<?php echo AuctionTheme_get_payments_page_url('deposit'); ?>" 		class="green_btn"><?php _e('Deposit Money','AuctionTheme'); ?></a>  
                <a href="<?php echo AuctionTheme_get_payments_page_url('makepayment'); ?>" 	class="green_btn"><?php _e('Make Payment','AuctionTheme'); ?></a> 
                <!-- <a href="<?php echo AuctionTheme_get_payments_page_url('escrow'); ?>" 		class="green_btn"><?php _e('Deposit Escrow','AuctionTheme'); ?></a> -->  
                <a href="<?php echo AuctionTheme_get_payments_page_url('withdraw'); ?>" 	class="green_btn"><?php _e('Withdraw Money','AuctionTheme'); ?></a>  
                <a href="<?php echo AuctionTheme_get_payments_page_url('transactions'); ?>" class="green_btn"><?php _e('Transactions','AuctionTheme'); ?></a>
                <a href="<?php echo AuctionTheme_get_payments_page_url('bktransfer'); ?>" 	class="green_btn"><?php _e('Bank Transfer Details','AuctionTheme'); ?></a>    
    
                  
                </div></div>
            </div>
            </div>
            
            <!-- ###################### -->
                        <div class="clear10"></div>
            
            <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e('Pending Withdrawals','AuctionTheme'); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
         				<?php
				
					global $wpdb;
					
					//----------------
				
					$s = "select * from ".$wpdb->prefix."auction_withdraw where done='0' AND uid='$uid' order by id desc";
					$r = $wpdb->get_results($s);
					
					if(count($r) == 0) echo __('No withdrawals pending yet.','AuctionTheme');
					else
					{
						echo '<table width="100%">';
						foreach($r as $row) // = mysql_fetch_object($r))
						{

							
							echo '<tr>';
							echo '<td>'.date('d-M-Y H:i:s', $row->datemade).'</td>';
							echo '<td>'.auctionTheme_get_show_price($row->amount).'</td>';
							echo '<td>'.$row->payeremail .'</td>';
							echo '<td><a href="'.AuctionTheme_get_payments_page_url('closewithdrawal', $row->id) .'"
							class="green_btn">'.__('Close Request','AuctionTheme'). '</a></td>';
							echo '</tr>';
							
							
						}
						echo '</table>';
						
					}
				
				?>
                  
                </div></div>
            </div>
            </div>
            
            
           <!-- ###################### -->
                        <div class="clear10"></div>
            
            <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e("Pending Incoming Payments","AuctionTheme"); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
   				<?php
				
					$s = "select * from ".$wpdb->prefix."auction_escrow where released='0' AND toid='$uid' order by id desc";
					$r = $wpdb->get_results($s);
					
					if(count($r) == 0) echo __('No payments pending yet.','AuctionTheme');
					else
					{
						echo '<table width="100%">';
						foreach($r as $row) // = mysql_fetch_object($r))
						{
							$post = get_post($row->pid);
							$from = get_userdata($row->fromid);
							
							echo '<tr>';
							echo '<td><a href="'.AuctionTheme_get_user_profile_link($from->ID).'">'.$from->user_login.'</a></td>';
							echo '<td>'.$post->post_title.'</td>';
							echo '<td>'.date('d-M-Y H:i:s', $row->datemade).'</td>';
							echo '<td>'.auctionTheme_get_show_price($row->amount).'</td>';
							
							echo '</tr>';
							
							
						}
						echo '</table>';
						
					}
				
				?>
                  
                </div></div>
            </div>
            </div>
         
         
                    <!-- ###################### -->
                        <div class="clear10"></div>
            
            <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e('Pending Outgoing Payments','AuctionTheme'); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
      				<?php
				
					$s = "select * from ".$wpdb->prefix."auction_escrow where released='0' AND fromid='$uid' order by id desc";
					$r = $wpdb->get_results($s);
					
					if(count($r) == 0) echo __('No payments pending yet.','AuctionTheme');
					else
					{
						echo '<table width="100%">';
						
						echo '<tr>';
							echo '<td><b>'.__('User','AuctionTheme').'</b></td>';
							echo '<td><b>'.__('Auction','AuctionTheme').'</b></td>';
							echo '<td><b>'.__('Date','AuctionTheme').'</b></td>';
							echo '<td><b>'.__('Amount','AuctionTheme').'</b></td>';
							echo '<td><b>'.__('Options','AuctionTheme').'</b></td>';
							
							echo '</tr>';
							
						
						foreach($r as $row) // = mysql_fetch_object($r))
						{
							$post = get_post($row->pid);
							$from = get_userdata($row->toid);
							
							echo '<tr>';
							echo '<td><a href="'.AuctionTheme_get_user_profile_link($from->ID).'">'.$from->user_login.'</a></td>';
							echo '<td><a href="'.get_permalink($post->ID).'">'.$post->post_title.'</a></td>';
							echo '<td>'.date_i18n('d-M-Y H:i:s', $row->datemade).'</td>';
							echo '<td>'.auctionTheme_get_show_price($row->amount).'</td>';
							echo '<td><a href="'.AuctionTheme_get_payments_page_url('releasepayment', $row->id).'"
							class="green_btn">'.__('Release Payment','AuctionTheme').'</a></td>';
							
							echo '</tr>';
							
							
						}
						echo '</table>';
						
					}
				
				?>
                  
                </div></div>
            </div>
            </div>
        <?php
			elseif($pg == 'escrow'):
		?>
        
        
        <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e('Make Escrow Payment','AuctionTheme'); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
                
                <?php
						
				$bal = auctionTheme_get_credits($uid);
				
				
				if(isset($_POST['escrowme']))
				{
					$amount 	= $_POST['amount'];
					$auctions 	= $_POST['auctionss'];
					$bid_id     = $_POST['bid_id'];
					
					if(!is_numeric($amount) || $amount < 0)
					{
						echo '<span class="newauction_error">'.__('Provide a well formated amount.','AuctionTheme').'</span><br/><br/>';
							
					}
					else if(empty($auctions))
					{
						echo '<span class="newauction_error">'.__('Please choose an auction.','AuctionTheme').'</span><br/><br/>';	
					}
					else
					{
						if($bal < $amount) 
						{
							echo '<div class="newauction_error marg_btm">'.sprintf(__('Your balance is smaller than the amount requested. <a href="%s">Click here</a> to deposit.','AuctionTheme'),
							AuctionTheme_get_payments_page_url('deposit')).'</div>';
						}
						else
						{
							$post 	= get_post($auctions);
							$uid2   = get_post_meta($auctions, "winner", true);
							
							$tm = current_time('timestamp',0);
							
							
							if($post->post_author != $uid)
								$uid2 = $post->post_author;	


							
							// for logged in user, the user who sends
							//======================================================
							$cr = auctionTheme_get_credits($uid);
							auctionTheme_update_credits($uid, $cr - $amount);
											
							//-----------------------
							$email 		= get_bloginfo('admin_email');
							$site_name 	= get_bloginfo('name');
							
							$usr = get_userdata($uid);
							
							$subject = __("Money Escrow Sent","AuctionTheme");
							$message = sprintf(__("You have placed in escrow the amount of: %s %s to user: 
							<b>%s</b>","AuctionTheme"),$amount,auctionTheme_currency(),$username);
	
							//sitemile_send_email($usr->user_email, $subject , $message);
							
							
							$s = "insert into ".$wpdb->prefix."auction_escrow (datemade, amount, fromid, toid, pid, bid_id) 
							values('$tm','$amount','$uid','$uid2','$auctions', '$bid_id')";
							$wpdb->query($s);
							
							//======================================================
							
							// for other user, the user who receives
							//======================================================
				
							$usr2 = get_userdata($uid2);
							
							$subject = __("Money Escrow Received","AuctionTheme");
							$message = sprintf(__("You have received in escrow the amount of: %s %s 
							from user: <b>%s</b>","AuctionTheme"),$amount,auctionTheme_currency(),$usr->user_login);
	
							//sitemile_send_email($usr2->user_email, $subject , $message);
							
							
							//======================================================
							
							echo '<span class="balance">'.__('Your payment has been sent. Redirecting...','AuctionTheme').'</span>';
							$url_redir = auctionTheme_get_payments_link(); //get_bloginfo('siteurl').'/my-account/payments/';
							echo '<meta http-equiv="refresh" content="2;url='.$url_redir.'" />';
						}
						
					}
					
				}
				
				
				$bal = auctionTheme_get_credits($uid);
				echo '<span class="balance">'.sprintf(__('Your Current Balance is: %s','AuctionTheme'), auctionTheme_get_show_price($bal))."</span><br/><br/>"; 
				
				?>
    				<br /><br />
                    <table>
                    <form method="post" >
                    <tr>
                    <td><?php _e('Escrow amount','AuctionTheme'); ?>:</td><td> 
                    <?php
					 
					global $wpdb;
						$id = $_GET['id'];
						$s = "select * from ".$wpdb->prefix."auction_bids where id='$id'";
						$r = $wpdb->get_results($s);
						$row = $r[0]; $bid = $row; $pid = $bid->pid; 
					 
					 
					$shipping = get_post_meta($pid, 'shipping', true);
					if(is_numeric($shipping) && $shipping > 0 && !empty($shipping))
						$shipping = $shipping;
					else 
						$shipping = 0;
			
				
					$quant_tk = $bid->quant;
					if($quant_tk > 0)
					{
						
							
						$prc = $bid->bid * $quant_tk + $shipping ;
					}
					else				
					echo $prc = $bid->bid + $shipping ; 
				
					
					?>
                    
                    <?php echo auctionTheme_get_show_price($prc, 2); ?></td>
                    </tr>
                    <tr>
                    <td><?php _e('Escrow for Auction','AuctionTheme'); ?>:</td><td> <?php /* $st = auction_get_my_awarded_auctions($uid);
					if($st == false) echo '<strong>'.__('You dont have any awarded auctions.','AuctionTheme').'</strong>'; else echo $st; */
                    	
						
						
						
						echo '<input type="hidden" value="'.$bid->pid.'" name="auctionss" />';
						echo '<input type="hidden" value="'.$prc.'" name="amount" />';
						echo '<input type="hidden" value="'.$id.'" name="bid_id" />';
						
						 
						$pst = get_post($bid->pid);
						echo $pst->post_title;
						
						//--------------------------------------
						
					
                    ?></td>
                    </tr>
                    
                    <tr>
                    <td></td>
                    <td>
                    <input type="submit" name="escrowme" value="<?php _e('Make Escrow','AuctionTheme'); ?>" /></td></tr></form></table>
    
                  
                </div></div>
            </div>
            </div> 
        
        
        
        <?php
			elseif($pg == 'bktransfer'):
		?>
        
        
        <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e('Set your Bank Transfer Details','AuctionTheme'); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
                
                <?php
						
				$bal = auctionTheme_get_credits($uid);
				
				
				if(isset($_POST['bank_details']))
				{
					$bank_details 	= $_POST['bank_details'];
					update_user_meta($uid, 'bank_details', $bank_details);
					echo '<div class="saved_thing">'.__("Details Saved","AuctionTheme") . "</div>";
					
				}
				
	
				?>
    				<br /><br />
                    <table>
                    <form method="post">
                    <tr>
                    <td valign="top"><?php _e("Bank details","AuctionTheme"); ?>:</td>
                    <td> <textarea cols="60" name="bank_details" rows="6"><?php echo get_user_meta($uid,'bank_details',true); ?></textarea></td>
                    </tr>
                  
                    
                    <tr>
                    <td></td>
                    <td>
                    <input type="submit" name="submit" value="<?php _e("Save Details","AuctionTheme"); ?>" /></td></tr></form></table>
    			
                  
                </div></div>
            </div>
            </div> 
        
        
        
        <?php
			elseif($pg == 'makepayment'):
		?>
        
          <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php echo __("Make Payment","AuctionTheme"); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
                
                <?php
						
				$bal = auctionTheme_get_credits($uid);
				
				
				if(isset($_POST['payme']))
				{
					$amount 	= $_POST['amount'];
					$username 	= $_POST['username'];
					
					if(!is_numeric($amount) || $amount < 0)
					{
						echo '<div class="newauction_error">'.__('Provide a well formated amount.','AuctionTheme').'</div><br/>';
							
					}
					else if(auctionTheme_username_is_valid($username) == false)
					{
						echo '<div class="newauction_error">'.__('Invalid username provided.','AuctionTheme').'</div><br/>'; 	
					}
					
					else if($username == $current_user->user_login)
					{
						echo '<div class="newauction_error">'.__('You cannot transfer money to your own account.','AuctionTheme').'</div><br/>';	
					}
					else
					{
						$min = get_option('auction_theme_transfer_limit');
						if(empty($min)) $min = 20;
					
						if($bal < $amount) 
						{
							echo '<div class="newauction_error">'.__('Your balance is smaller than the amount requested.','AuctionTheme').'</div><br/>';
						}
						else if($amount < 10)
						{
							echo '<div class="newauction_error">'.__('The amount should not be less than','AuctionTheme').' 10.00 '.auctionTheme_currency().'.</div>
							<br/><br/>';
						}
						else
						{
							$tm = current_time('timestamp',0);
							$uid2 = auctionTheme_get_userid_from_username($username);
							
							// for logged in user, the user who sends
							//======================================================
							$cr = auctionTheme_get_credits($uid);
							auctionTheme_update_credits($uid, $cr - $amount);
											
							//-----------------------
							$email 		= get_bloginfo('admin_email');
							$site_name 	= get_bloginfo('name');
							
							$usr = get_userdata($uid);
							
							$subject = __("Money Sent","AuctionTheme");
							$message = sprintf(__("You have sent amount of: %s %s to user: <b>%s</b>","AuctionTheme")
							,$amount,auctionTheme_currency(),$username);
	
							//sitemile_send_email($usr->user_email, $subject , $message);
							
							$reason = sprintf(__("Amount transfered to user %s","AuctionTheme"),$username);
							auctionTheme_add_history_log('0', $reason, $amount, $uid, $uid2);
							
							//======================================================
							
							// for other user, the user who receives
							//======================================================
							
							$cr = auctionTheme_get_credits($uid2);
							auctionTheme_update_credits($uid2, $cr + $amount);
											
												
							$usr2 = get_userdata($uid2);
							
							$subject = __("Money Received","AuctionTheme");
							$message = sprintf(__("You have received amount of: %s %s from user: <b>%s</b>","AuctionTheme"),
							$amount,auctionTheme_currency(),$usr->user_login);
	
							//sitemile_send_email($usr2->user_email, $subject , $message);
							
							$reason = sprintf(__("Amount transfered from user %s","AuctionTheme"), $usr->user_login);
							auctionTheme_add_history_log('1', $reason, $amount, $uid2, $uid);
							
							//======================================================
							
							echo '<span class="balance">'.__('Your payment has been sent. Redirecting...','AuctionTheme').'</span>';
							$url_redir = get_bloginfo('siteurl').'/my-account/payments/';
							echo '<meta http-equiv="refresh" content="2;url='.$url_redir.'" />';
						}
						
					}
					
				}
				
				
				$bal = auctionTheme_get_credits($uid);
				echo '<span class="balance">'. sprintf(__("Your Current Balance is %s","AuctionTheme"), auctionTheme_get_show_price($bal)).":</span><br/><br/>"; 
				
				?>
    				<br /><br />
                    <table>
                    <form method="post" enctype="application/x-www-form-urlencoded">
                    <tr>
                    <td><?php echo __("Payment amount","AuctionTheme"); ?>:</td>
                    <td> <input value="<?php echo $_POST['amount']; ?>" type="text" 
                    size="10" name="amount" /> <?php echo auctionTheme_currency(); ?></td>
                    </tr>
                    <tr>
                    <td><?php echo __("Pay to user","AuctionTheme"); ?>:</td>
                    <td><input value="<?php echo $_POST['username']; ?>" type="text" size="30" name="username" /></td>
                    </tr>
                    
                    <tr>
                    <td></td>
                    <td>
                    <input type="submit" name="payme" value="<?php echo __("Make Payment","AuctionTheme"); ?>" /></td></tr></form></table>
    
                  
                </div></div>
            </div>
            </div> 
        
              
        <?php    
            elseif($pg == 'withdraw'):	
			
		?>
        
        
               <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e("Request Withdrawal","AuctionTheme"); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
                
                <?php
						
				$bal = auctionTheme_get_credits($uid);
				echo '<span class="balance">';
				printf(__('Your Current Balance is: %s','AuctionTheme'), auctionTheme_get_show_price($bal)); 
				echo "</span><br/><br/>"; 
				
				if(isset($_POST['withdraw']))
				{
					$amount = $_POST['amount'];
					$paypal = $_POST['paypal'];
					
					if(!is_numeric($amount) || $amount < 0)
					{
						echo '<span class="newauction_error">'.__('Provide a well formated amount.','AuctionTheme').'</span>';
							
					}
					else if(auction_isValidEmail($paypal) == false)
					{
						echo '<span class="newauction_error">'.__('Invalid email provided.','AuctionTheme').'</span>';	
					}
					else
					{
						$min = get_option('auction_theme_min_withdraw');
						if(empty($min)) $min = 50;
					
						if($bal < $amount) 
						{
							echo '<span class="newauction_error">'.__('Your balance is smaller than the amount requested.','AuctionTheme').'</span>';
						}
						else if($amount < $min)
						{
							echo '<span class="newauction_error">'.sprintf(__('The amount should not be less than %s','AuctionTheme'),
							auctionTheme_get_show_price($min,2)).'.</span>';
						}
						else
						{
							$tm = current_time('timestamp',0); global $wpdb;
							$s = "insert into ".$wpdb->prefix."auction_withdraw (payeremail, amount, datemade, uid) 
							values('$paypal','$amount','$tm','$uid')";
							$wpdb->query($s);
							
							$cr = auctionTheme_get_credits($uid);
							auctionTheme_update_credits($uid, $cr - $amount);
							
							//-----------------------
							$email 		= get_bloginfo('admin_email');
							$site_name 	= get_bloginfo('name');
							
							$usr = get_userdata($uid);
							
							$subject = __("Money Withdraw Requested","AuctionTheme");
							$message = sprintf(__("You have requested a new withdrawal of: %s","AuctionTheme"), $amount." ".auctionTheme_currency());
	
							//sitemile_send_email($usr->user_email, $subject , $message);
							
							//-----------------------
							
							echo '<span class="balance">'.__('Your request has been queued. Redirecting...','AuctionTheme').'</span>';
							$url_redir = get_bloginfo('siteurl').'/my-account/payments/';
							echo '<meta http-equiv="refresh" content="2;url='.$url_redir.'" />';
						}
						
					}
					
				}
				
				global $current_user;
				get_currentuserinfo();
				$uid = $current_user->ID;
				
				
				?>
    				<br /><br />
                    <table>
                    <form method="post" enctype="application/x-www-form-urlencoded">
                    <tr>
                    <td><?php echo __("Withdraw amount","AuctionTheme"); ?>:</td>
                    <td> <input value="<?php echo $_POST['amount']; ?>" type="text" 
                    size="10" name="amount" /> <?php echo auctionTheme_currency(); ?></td>
                    </tr>
                    <tr>
                    <td><?php echo __("PayPal Email","AuctionTheme"); ?>:</td>
                    <td><input value="<?php echo get_user_meta($uid, 'paypal_email',true); ?>" type="text" size="30" name="paypal" /></td>
                    </tr>
                    
                    <tr>
                    <td></td>
                    <td>
                    <input type="submit" name="withdraw" value="<?php echo __("Withdraw","AuctionTheme"); ?>" /></td></tr></form></table>
    
                  
                </div></div>
            </div>

            </div>
            
        
            
        <?php    
            elseif($pg == 'deposit'):	
			
			
			global $am_err;
			
			if($am_err == 1)
			{
				echo '<div class="errrs3">'.__('Please input a proper amount.','AuctionTheme').'</div>';	
				
			}
			
			
		?>
        
        
    
        <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e('Deposit Money','AuctionTheme'); ?></div>
            	<div class="box_content">
                <div class="padd10">
                
                <strong><?php _e('Deposit money by PayPal','AuctionTheme'); ?></strong><br/><br/>
                
                <form method="post">
                Amount to deposit: <input type="text" size="10" name="amount" /> <?php echo auctionTheme_currency(); ?>
                &nbsp; &nbsp; <input type="submit" name="deposit_pay_me" value="<?php _e('Deposit','AuctionTheme'); ?>" /></form>
    
    
                  
                </div></div>
            </div>
            </div>
        
        <?php    
            elseif($pg == 'transactions'):	
			
		?>	
		
        		
            <div class="my_box3">
            <div class="padd10">
            
            	<div class="box_title"><?php _e('Payment Transactions','AuctionTheme'); ?> </div>
            	<div class="box_content">
                <div class="padd10">
                
                <?php
				
					$s = "select * from ".$wpdb->prefix."auction_payment_transactions where uid='$uid' order by id desc";
					$r = $wpdb->get_results($s);
					
					if(count($r) == 0) echo __('No activity yet.','AuctionTheme');
					else
					{
						$i = 0;
						echo '<table width="100%" cellpadding="5">';
						foreach($r as $row) // = mysql_fetch_object($r))
						{
							if($row->tp == 0){ $class="redred"; $sign = "-"; }
							else { $class="greengreen"; $sign = "+"; }
							
							echo '<tr style="background:'.($i%2 ? "#f2f2f2" : "#f9f9f9").'" >';
							echo '<td>'.$row->reason.'</td>';
							echo '<td width="25%">'.date('d-M-Y H:i:s',$row->datemade).'</td>';
							echo '<td width="20%" class="'.$class.'"><b>'.$sign.auctionTheme_get_show_price($row->amount).'</b></td>';
							
							echo '</tr>';
							$i++;
						}
						
						echo '</table>';
						
						
					}
				
				?>
    
                  
                </div></div>
            </div>
            </div>
        
        
        	
		<?php endif; ?>  
        
        
        </div>


<?php	auctionTheme_get_users_links();	
}

?>